<?php
namespace Admin\Controller;

class PublicController extends \Think\Controller{
	
	//后台登陆
	public function login(){
		$this->display();
	}
	
	//后台登陆验证
	public function checkLogin(){
		if(IS_AJAX){
			$data['username'] = I("post.username");
	    	$data['password'] = I("post.password");
	    	$admin = D('admin');
	    	$is_login	=	$admin->doLogin($data);
	    	if($is_login > 0){
	    		//记录行为
                action_log('登陆系统','public',$is_login,$is_login,$data['username']);
	    		$msg_data['status']	= 1;
	    		$msg_data['msg']	= '登陆成功';
	    		$this->ajaxReturn($msg_data);
	    	}else{
	    		$msg_data['status']	= 0;
	    		$msg_data['msg']	= $is_login;
	    		$this->ajaxReturn($msg_data);
	    	}
		}else{
			$this->error("非法操作");
		}
	}
	/*后台退出*/
	public function logout(){
        if(is_login()){
            session('user_auth', null);
        	session('user_auth_sign', null);
            $this->success('退出成功！', U('Public/login'));
        } else {
            $this->redirect('Public/login');
        }
    }
}
?>